package com.ss.android.article.browser.a;

import android.graphics.Bitmap;
import android.net.Uri;
import android.support.annotation.NonNull;
import android.util.Log;

import com.a.a.c;
import com.a.a.NightMode;

import java.io.Closeable;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStream;

import inline.FileUtils;

final class d implements NightMode {
    private final a c;
    private final String a;
    private final Bitmap b;

    d(a arg1, String arg2, Bitmap arg3) {
        this.c = arg1;
        this.a = arg2;
        this.b = arg3;

    }

    public final void f(@NonNull Object arg5) {
        Closeable v1_1;
        FileOutputStream v1 = null;
        Uri v0 = android.support.design.a.t(this.a);
        if(v0 == null) {
            ((c)arg5).onComplete();
            return;
        }

        Log.d("FaviconModel", "Caching icon for " + v0.getHost());
        Closeable v2 = null;
        try {
            v1 = new FileOutputStream(com.ss.android.article.browser.a.a.a(com.ss.android.article.browser.a.a.a(this.c), v0));
            this.b.compress(Bitmap.CompressFormat.PNG, 100, ((OutputStream)v1));
            v1.flush();
        } catch(IOException v0_2) {
                Log.e("FaviconModel", "Unable to cache favicon", ((Throwable)v0_2));
        }finally {
            FileUtils.a(((Closeable)v1));
        }

    }
}

